//空间管理
(function() {
	var config = require("../_include/config");
	var db = require("../db/index");
	var md5 = require("../_include/md5");
	var helper = require("../_include/helper");
	var db_table_name = config.dbname.express;
	var db_id_prefix = config.dbIdPrefix.express;
	var UserCon = require("../user/_con");
	var BusCon = require("../bus/_con");
	//构造函数
	var _con = function(info) {
		var self = this;
		self._id = db_id_prefix + Math.random().toString(16).substr(2) + (+new Date).toString(16);
		if (!BusCon.get(info.bus_id)) {
			throwCusError("找不到指定商家");
		}
		self.bus_id = info.bus_id;
		self.setInfo(info);

		db.insert(db_table_name, self);
		console.log("创建了一个运费模板：", info.name);
	};

	module.exports = _con;

	//技能
	_con.prototype = require("./skill");

	//静态方法
	_con.get = function(Id) {
		var result = db.find_by_id(db_table_name, Id);
		return _con.getInstance(result);
	};
	_con.getInstance = function(obj) {
		if (obj) {
			obj.__proto__ = _con.prototype;
		}
		return obj;
	};
}());